                            <? $frmtime = time(); ?>
                            <div class="main">
                                <h3 class="title"><?=$clabel?> &raquo; <?=$mlabel?></h3>
                                <div class="formdiv">
                                    <form method="POST" id="frmAddVehicle<?=$frmtime?>">
                                        <table>
                                            <? if( isset($errors) ) {
                                               foreach($errors as $error) {
                                               ?>
                                            <tr>
                                                <td class="errormsg" colspan="3">
                                                    <?=$error?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <? if( isset($successes) ) {
                                               foreach($successes as $success) {
                                               ?>
                                            <tr>
                                                <td class="successmsg" colspan="3">
                                                    <?=$success?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <tr>
                                                <td><label for="vh_no">Bus No.*</label></td>
                                                <td>
                                                    <input type="text" class="text required" maxlength="10" minlength="1"  name="vh_no" value="<?=$postdata['vh_no']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_make">Make*</label></td>
                                                <td>
                                                    <input type="text" class="text required" maxlength="100" minlength="3"  name="vh_make" value="<?=$postdata['vh_make']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_model<?=$frmtime?>">Model*</label></td>
                                                <td>
                                                    <select id="vh_model<?=$frmtime?>" class="text required" name="vh_model">
                                                        <option value="">-- Select --</option>
                                                        <?
                                                            $curYear = date('Y')+1;

                        	                               for( $year = 1995; $year <= $curYear; $year++ ) {
                        	                                   $sel = '';
                        	                                   if(isset($postdata["vh_model"]) && $year==$postdata["vh_model"]) { $sel = "selected"; }
                                                        ?>
                                                            <option value="<?=$year?>" <?=$sel?>><?=$year?></option>
                                                        <?
                        	                               }

                                                        ?>
                                                    </select>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_capacity">Capacity*</label></td>
                                                <td>
                                                    <input type="text" class="text required number" maxlength="3" minlength="1"  name="vh_capacity" value="<?=$postdata['vh_capacity']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_reg_no">Registration No.*</label></td>
                                                <td>
                                                    <input type="text" class="text required" maxlength="20" minlength="3"  name="vh_reg_no" value="<?=$postdata['vh_reg_no']?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_reg_expiry<?=$frmtime?>">Registration Expiry*</label></td>
                                                <td>
                                                    <input type="text" readonly="true" class="stext required {validate:{date:true}}" id="vh_reg_expiry<?=$frmtime?>" name="vh_reg_expiry" value="<?=$postdata['vh_reg_expiry']?>" />
                                                    <label>YYYY-MM-DD</label>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_first_reg_date<?=$frmtime?>">Date of First Regn.*</label></td>
                                                <td>
                                                    <input type="text" readonly="true" class="stext required {validate:{date:true}}" id="vh_first_reg_date<?=$frmtime?>" name="vh_first_reg_date" value="<?=$postdata['vh_first_reg_date']?>" />
                                                    <label>YYYY-MM-DD</label>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_owner<?=$frmtime?>">Owner</label></td>
                                                <td>
                                                    <input type="text" class="text" name="vh_owner" value="<?=$postdata['vh_owner']?>" id="vh_owner<?=$frmtime?>" />
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_owner_tel<?=$frmtime?>">Owner's Tel.*</label></td>
                                                <td>
                                                    <input type="text" class="text digits" name="vh_owner_tel" value="<?=$postdata['vh_owner_tel']?>"  id="vh_owner_tel<?=$frmtime?>"/>
                                                </td>
                                                <td></td>
                                            </tr>                                            
                                            <tr>
                                                <td><label for="vh_route<?=$frmtime?>">Route</label></td>
                                                <td>
                                                    <select id="vh_route<?=$frmtime?>" class="text" name="vh_route">
                                                        <option value="">-- Select --</option>
                                                        <?
                                                            if(isset($routelist) && is_array($routelist) && count($routelist) > 0) {
                            	                               foreach( $routelist as $route ) {
                            	                                   $sel = '';
                            	                                   if(isset($postdata["vh_route"]) && $route["value"]==$postdata["vh_route"]) { $sel = "selected"; }
                                                        ?>
                                                                <option value="<?=$route["value"]?>" <?=$sel?>><?=$route["label"]?></option>
                                                        <?
                            	                           }
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_driver<?=$frmtime?>">Driver</label></td>
                                                <td>
                                                    <select id="vh_driver<?=$frmtime?>" class="text" name="vh_driver">
                                                        <option value="">-- Select --</option>
                                                        <?
                                                            if(isset($driverlist) && is_array($driverlist) && count($driverlist) > 0) {
                            	                               foreach( $driverlist as $driver ) {
                            	                                   $sel = '';
                            	                                   if(isset($postdata["vh_driver"]) && $driver["value"]==$postdata["vh_driver"]) { $sel = "selected"; }
                                                        ?>
                                                                <option value="<?=$driver["value"]?>" <?=$sel?>><?=$driver["label"]?></option>
                                                        <?
                            	                           }
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td></td>
                                            </tr>
                                            <tr>
                                                <td><label for="vh_helper<?=$frmtime?>">Helper</label></td>
                                                <td>
                                                    <select id="vh_helper<?=$frmtime?>" class="text" name="vh_helper">
                                                        <option value="">-- Select --</option>
                                                        <?
                                                            if(isset($helperlist) && is_array($helperlist) && count($helperlist) > 0) {
                            	                               foreach( $helperlist as $helper ) {
                            	                                   $sel = '';
                            	                                   if(isset($postdata["vh_helper"]) && $helper["value"]==$postdata["vh_helper"]) { $sel = "selected"; }
                                                        ?>
                                                                <option value="<?=$helper["value"]?>" <?=$sel?>><?=$helper["label"]?></option>
                                                        <?
                            	                           }
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td></td>
                                            </tr>
                                        	<tr>
                                        		<td></td>
                                        		<td colspan="2">
                                                    <input class="button" type="submit" name="btnAddVehicle" value="Add" id="btnAddVehicle<?=$frmtime?>" />
                                                    <input class="button" type="reset" value="Cancel" id="btnreset<?=$frmtime?>" />
                                                </td>
                                        	</tr>
                                        </table>
                                	</form>
                                    <script language="javascript" type="text/javascript">
                                        if(typeof jQuery == 'undefined') {
                                            alert('Invalid Request');
                                            window.location = "/";
                                        }
                                        $(document).ready( function() {
                                            var frmObj = $("#frmAddVehicle<?=$frmtime?>");
                                            $("#frmAddVehicle<?=$frmtime?>").validate({
                                                errorPlacement: function(error, element) {
                                                    placeError(error, element);
                                                },
                                                submitHandler: function(form) {
                                                    var cui = $('#contenttabs .ui-tabs-panel:visible');                                                                                                        
                                               	    var jqxhr = $.post(
                                                        "/transport/addvehicle", 
                                                        $("#frmAddVehicle<?=$frmtime?>").serialize(), 
                                                        function (data) {
                                                            $(cui).html(data);
                                                        }
                                                    );
                                                    $(cui).html('<div id="loadingdiv"><div class="centerdiv"><strong>Processing</strong><br/><img src="/images/ajaxloader.gif" /></div></div>');
                                                }
                                            });
                                            $(".chzn-select",frmObj).chosen({no_results_text: "No results matched"});
                                            $("input[name='vh_reg_expiry']",frmObj).datepicker({ 
                                                dateFormat: 'yy-mm-dd',
                                                changeMonth: true,
                                                changeYear: true
                                            });
                                            $("input[name='vh_first_reg_date']",frmObj).datepicker({ 
                                                dateFormat: 'yy-mm-dd',
                                                changeMonth: true,
                                                changeYear: true,
                                                maxDate: new Date() 
                                            });
                                            $("input[type='reset']",frmObj).click( function() {
                                                $('label.error',frmObj).remove();
                                            });
                                            
                                            
                                        });
                                    </script>
                                 </div>
                            </div>